
package com.hserver.deploy.init;

import com.hserver.deploy.config.SqlConfig;
import com.hserver.deploy.utils.FileUtil;
import top.hserver.core.interfaces.InitRunner;
import top.hserver.core.ioc.annotation.Bean;

import java.io.File;
import java.io.InputStream;

@Bean
public class RunInit implements InitRunner {

    @Override
    public void init(String[] args) {
        String path = System.getProperty("user.dir") + File.separator + "shell/";
        File file = new File(path);
        if (!file.exists()) {
            file.mkdirs();
        }
        InputStream is = SqlConfig.class.getResourceAsStream("/shell/isrunning.sh");
        FileUtil.copyFile(is, path + "isrunning.sh");
        is = SqlConfig.class.getResourceAsStream("/shell/kill.sh");
        FileUtil.copyFile(is, path + "kill.sh");
        is = SqlConfig.class.getResourceAsStream("/shell/package.sh");
        FileUtil.copyFile(is, path + "package.sh");
        is = SqlConfig.class.getResourceAsStream("/shell/showlog.sh");
        FileUtil.copyFile(is, path + "showlog.sh");
        is = SqlConfig.class.getResourceAsStream("/shell/start.sh");
        FileUtil.copyFile(is, path + "start.sh");
    }
}
